<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<meta name="author" content="order by dede58.com" />
		<title>会员登录</title>
		<link rel="stylesheet" type="text/css" href="./css/login.css">
		<script type="text/javascript" src="js/jquery1.9.1.js"></script>
		<script type="text/javascript" src="js/jquery.validate.min.js"></script>
		<script type="text/javascript" src="js/common.js"></script>
		<style>
			.error {
				color: red;
			}
		</style>
	</head>

	<body>
		<!-- login -->
		<div class="top center">
			<div class="logo center">
				<a href="./index.html" target="_blank"><img src="./image/logo.png" alt="" width="200" height="80"></a>
			</div>
		</div>
		<form method="post" class="form center" id="login-form">

			<div class="login">
				<div class="login_center">

					<div class="login_top">
						<div class="left fl">会员登录</div>
						<div class="right fr">您还不是我们的会员？
							<a href="./register.html" target="_self">立即注册</a>
						</div>
						<div class="clear"></div>
						<div class="xian center"></div>
					</div>
					<div class="login_main center">
						<span id="error" class="error"></span>
						<div class="username">用户名:&nbsp;<input class="shurukuang" type="text" name="name" placeholder="请输入你的用户名" /></div>
						<div class="username">密&nbsp;&nbsp;&nbsp;&nbsp;码:&nbsp;<input class="shurukuang" type="password" name="pwd" placeholder="请输入你的密码" /></div>

					</div>
					<div class="login_submit">
						<input class="submit" type="submit" name="submit" value="立即登录">
					</div>

				</div>
			</div>
		</form>
	</body>
	<script>
		$("#login-form").validate({
			rules: {
				name: {
					required: true
				},
				pwd: {
					required: true
				}
			},
			messages: {
				name: {
					required: "请输入用户名"
				},
				pwd: {
					required: "请输入密码"
				}
			},
			errorPlacement: function(error, element) {
				element.parent().after(error);
			},
			submitHandler: function(form) {
				$.ajax({
					url:serverPath+"user/login",
					type:"post",
					data:$("#login-form").serialize(),
					xhrFields: {
						withCredentials: true
					},
					success:function(res){
						if(res.code==200){
							location.href="index.html";
							$("#error").html("");
						}
					},error:function(res){
						$("#error").html(JSON.parse(res.responseText).error);
					}
				});
				return false;
			}
		});
		
		
	</script>

</html>